import request from '@/utils/request'

// 查询生产计划列表
export function listWorkorder(query) {
  return request({
    url: '/mes/pro/plan/list',
    method: 'get',
    params: query
  })
}

// 新增生产工单
export function addWorkorder(data) {
  return request({
    url: '/mes/pro/plan/add',
    method: 'post',
    data: data
  })
}

// 删除生产计划单
export function delWorkorder(workorderId) {
  return request({
    url: '/mes/pro/plan/del/' + workorderId,
    method: 'delete'
  })
}

// 关闭生产计划单
export function closePlan(workorderId) {
  return request({
    url: '/mes/pro/plan/closePlan/' + workorderId,
    method: 'post'
  })
}

// 分解生产计划单
export function decomposePlan(workorderId) {
  return request({
    url: '/mes/pro/plan/decomposePlan/' + workorderId,
    method: 'post'
  })
}

// 完成生产计划单
export function finishPlan(workorderId) {
  return request({
    url: '/mes/pro/plan/finishPlan/' + workorderId,
    method: 'post'
  })
}

// 撤回生产计划单
export function withdrawPlan(workorderId) {
  return request({
    url: '/mes/pro/plan/withdrawPlan/' + workorderId,
    method: 'post'
  })
}







// 查询生产工单详细
export function getWorkorder(workorderId) {
  return request({
    url: '/mes/pro/workorder/' + workorderId,
    method: 'get'
  })
}

//查询生产工单，并携带每个生产工单下生产任务的情况
export function listWithTaskJson(query) {
  return request({
    url: '/mes/pro/workorder/listWithTaskJson',
    method: 'get',
    params: query
  })
}

// 修改生产工单
export function updateWorkorder(data) {
  return request({
    url: '/mes/pro/plan/edit',
    method: 'put',
    data: data
  })
}

// 查询物料依赖列表
export function listItems(query) {
  return request({
    url: '/mes/pro/workorder/listItems',
    method: 'get',
    params: query
  })
}

export function dofinish(workorderId){
  return request({
    url: '/mes/pro/workorder/'+workorderId,
    method: 'put'
  })
}

//查询计划单物料明细
export function listProPlanMaterielDetail(proPlanId) {
  return request({
    url: '/mes/pro/plan/listProPlanMaterielDetail/' + proPlanId,
    method: 'get',
  })
}

//查询查询计划产品BOM清单
export function listProPlanProductBOM(proPlanId) {
  return request({
    url: '/mes/pro/plan/listProPlanProductBOM/' + proPlanId,
    method: 'get',
  })
}

//查询查询计划产品BOM清单}
export function listProPlanWorkOrder(proPlanId) {
  return request({
    url: '/mes/pro/plan/listProPlanWorkOrder/' + proPlanId,
    method: 'get',
  })
}


// 完成生产工单
export function finishWorkorder(workorderId) {
  return request({
    url: '/mes/pro/workorder/' + workorderId,
    method: 'put'
  })
}

// //查询查询计划物料明细
// export function listProPlanMaterielDetail(proPlanId) {
//   return request({
//     url: '/mes/pro/plan/listProPlanMaterielDetail/' + proPlanId,
//     method: 'get',
//   })
// }